@using CodeGenerator
@using RazorLight
@using BXJG.Common;
@using BXJG.Common.Extensions;
@inherits TemplatePage<ExecuteContext>
@{
    DisableEncoding = true;//禁止html编码，因为我们是做代码生成器
}
@("@using") @Model.Model.ApplicationShareNamespace
@@using BXJG.Utils.Application.Share.Dtos
@@using Microsoft.AspNetCore.Components.Sections

@@inherits TreeDetailUpdateBaseComponent<@Model.Model.DtoName, @Model.Model.EditDtoName>

<SectionContent SectionName=@@($"{Master}-detail-update-title")>
    <Icon Type=@@detailUpdateIcon Theme=@@IconThemeType.Outline />
    @@(detailUpdateText)@@(FuncName)
</SectionContent>
<SectionContent SectionName=@@($"{Master}-detail-update-body")>
    @@if (isEdit)
    {
        <Form @@ref="frm" ValidateOnChange="true" Model="editDto" LabelColSpan="4" WrapperColSpan="20" OnFinish="OnFinish" Loading="IsBusy">
            <FormItem>
                <Input @@bind-Value="context.DisplayName" AllowClear="true" />
            </FormItem>
@foreach(var field in Model.Model.NormalFields)
{
    if(field.CSharpType == "bool"){
        <FormItem Label="@field.DisplayName">
            <Switch @@bind-Checked="context.@field.Name" />
        </FormItem>
    }
    else if(field.CSharpTypeIsNumber){
        <FormItem>
            <AntDesign.InputNumber @@bind-Value="context.@field.Name"
                                @if(field.NumberPrecision.HasValue){
                                    @:Precision="@field.NumberPrecision"
                                }
                                @if(field.NumberMax.HasValue){
                                    @:Max="@(field.NumberMaxSymbol)"
                                }
                                @if(field.NumberMin.HasValue){
                                    @:Min="@(field.NumberMinSymbol)"
                                }/>
        </FormItem>
    }
    else if(field.CSharpTypeIsDateTime){
        <FormItem>
            <AntDesign.DatePicker @@bind-Value="context.@field.Name"  AllowClear="true"/>
        </FormItem>
    }
    else{    
        <FormItem>
            <Input @@bind-Value="context.@field.Name"  AllowClear="true" />
        </FormItem>
    }
}
        </Form>
    }
    else
    {
        <GridRow>
            <GridCol Span="5">名称</GridCol>   
            <GridCol Span="19">@@dto.DisplayName</GridCol>
        </GridRow>
@foreach(var field in Model.Model.NormalFields)
{ 
        <GridRow>
            <GridCol Span="5">@field.DisplayName</GridCol>     
    @if(field.CSharpType== "bool"){
            <GridCol Span="19"><Switch Checked=dto.@field.Name Disabled="true" /></GridCol>
    }
    else{    
            <GridCol Span="19">@@dto.@field.Name</GridCol>  
    }
       </GridRow>
}
    }
</SectionContent>
<SectionContent SectionName=@@($"{Master}-detail-update-btns")>
    @@if (IsShowDelete)
    {
        <Popconfirm Title="确定删除此项吗?" OnConfirm="BtnDeleteClick" Disabled="IsBusy">
            <Button Loading="isDeleting" Danger="true" Disabled="IsBusy">删除</Button>
        </Popconfirm>
    }
    <ButtonGroup>
        @@if (IsShowRefresh)
        {
            <Button OnClick="BtnRefreshClick" Loading="isRefreshing" Disabled="IsBusy">刷新</Button>
        }
        @@if (IsShowBeginEdit)
        {
            <Button OnClick="BtnBeginEditClick" Loading="isFormIniting" Type="@@ButtonType.Primary">修改</Button>
        }
        else if (IsShowUpdate)
        {
            <Button OnClick="BtnResetClick" Loading="isReseting" Disabled="IsBusy" Icon="@@IconType.Outline.Redo">重置</Button>
            <Button OnClick="BtnCancelEditClick" Disabled="IsBusy" Icon="@@IconType.Outline.Rollback">放弃修改</Button>
            <Button OnClick="BtnUpdateClick" Type="@@ButtonType.Primary" Loading="isUpdating" Disabled="IsBusy" Icon="@@IconType.Outline.Save">保存</Button>
        }
    </ButtonGroup>
</SectionContent>